package com.macroye.service.impl;

import com.macroye.entity.BrokerHomePage;
import com.macroye.entity.HomePageConfig;
import com.macroye.entity.req.BrokerLoginVo;
import com.macroye.result.Result;
import com.macroye.mapper.BrokerMapper;
import com.macroye.service.BrokerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class BrokerServiceImpl implements BrokerService {


    @Autowired
    BrokerMapper brokerMapper;

    @Autowired
    RedisTemplate<String,Object> redisTemplate;

    @Autowired
    HttpServletRequest request;

    /**
     * 经纪人登录
     * @param broker
     * @return
     */
    @Override
    public Result<BrokerLoginVo> brokerLogin(BrokerLoginVo broker) {
        BrokerLoginVo user=brokerMapper.brokerLogin(broker);
        return Result.success(user);
    }

    /**
     * 查找经纪人首页信息
     * @return
     */
    @Override
    public Result<BrokerHomePage> findHomePageInfotmation() {
        //获取当前用户信息
        BrokerLoginVo vBroker = InformationCommonImpl.findVBroker(redisTemplate, request);
        BrokerHomePage brokerHomePage = brokerMapper.findHomeInformation(vBroker.getId());
        return Result.success(brokerHomePage);
    }
}
